﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.Linq;
using System.Data.Linq.Mapping;

using System.Collections.Generic;
namespace WF
{
    public partial class WebTest : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //List<string> list = new List<string> { "asp", "C#", "C++", "javascript" };
            //IEnumerable<string> result = list.Where(delegate(string s)
            //{
            //    return s.IndexOf("a") >= 0;
            //});
            //foreach (string s in result)
            //{
            //    Console.WriteLine(s);
            //}

            //var numbers = new int[] { 2, 56, 98, 1, 78, 14, 36 };
            //var evenNumbers = from p in numbers
            //                  where (p % 2) == 0
            //                  select p;
            //Console.WriteLine("Result:");
            //foreach (var val in evenNumbers)
            //{
            //    Console.WriteLine(val);
            //}

            //var result = from c in CreateCustom()
            //             where c.City == "Beijing"
            //             select c;
            //Console.WriteLine("在Beijing的客戶有:");
            //foreach (var v in result)
            //{
            //    Console.WriteLine(v.CustomID);
            //}
            //Console.ReadLine();

            var db = new DataContext("Data Source=ewftest;User ID=ewf;Password=test");
            var result = from c in db.GetTable<A>()
                         where c.Key == "此流程為子流程"
                         select c;
            foreach (var v in result)
            {
                Response.Write(string.Format("{0}\t{1}", v.Key, v.Value));
            }
        }

        static IEnumerable<A> CreateCustom()
        {
            return new List<A>
            {
                new A{Key = "123",Value="Beijing"},
                new A{Key = "124",Value="Zhongshan"},
                new A{Key = "125",Value="Heyuan"},
                new A{Key = "126",Value="Shenzhen"},
                new A{Key = "127",Value="Shanghai"},
                new A{Key = "128",Value="Shenzhen"},
                new A{Key = "120",Value="Beijing"},
                new A{Key = "129",Value="Beijing"}
            };
        }

        [Table(Name = "TA")]
        public class A
        {
            [Column]
            public string Key { get; set; }
            [Column]
            public string Value { get; set; }
            [Column]
            public string EN { get; set; }
            [Column]
            public string VN { get; set; }
            public override string ToString()
            {
                return Key + "\t" + Value;
            }

        }


    }

}
